home *** CD-ROM | disk | FTP | other *** search
/ Geni@l B1 3 / Geni@l B1 3.iso / setup.exe / {app} / collector / utils.pyc (.txt) < prev   
Python Compiled Bytecode  |  2009-02-11  |  4KB  |  115 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from models import User
  5. from django.conf import settings
  6.  
  7. class DummyProfile:
  8.     user = None
  9.     viewed_exercises = None
  10.     finished_exercises = None
  11.     visit = None
  12.     
  13.     def get_visit(self):
  14.         pass
  15.  
  16.     
  17.     def set_visit(self, value):
  18.         pass
  19.  
  20.     
  21.     def get_viewed_exercises(self):
  22.         pass
  23.  
  24.     
  25.     def set_viewed_exercises(self, value):
  26.         pass
  27.  
  28.     
  29.     def get_finished_exercises(self):
  30.         pass
  31.  
  32.     
  33.     def set_finished_exercises(self, value):
  34.         pass
  35.  
  36.     
  37.     def get_finished_exercises_grouped(self, volume):
  38.         return { }
  39.  
  40.     
  41.     def get_username(self):
  42.         return ''
  43.  
  44.     
  45.     def save(self):
  46.         pass
  47.  
  48.  
  49. if settings.IS_SBX:
  50.     
  51.     def get_pupil_profile(request):
  52.         effective_username_field = u'_'.join([
  53.             request.ProjectName,
  54.             'sbx_id'])
  55.         if effective_username_field not in request.session:
  56.             return DummyProfile()
  57.         
  58.         user = User.objects.get(sbxid = request.session[effective_username_field], project = request.ProjectName)
  59.         return request.ProjectSettings.UserProfile.objects.get(user = user)
  60.  
  61.     
  62.     def login_pupil(request, username):
  63.         (user, created) = User.objects.get_or_create(sbxid = username, project = request.ProjectName)
  64.         if created:
  65.             user.save()
  66.             profile = request.ProjectSettings.UserProfile(user = user)
  67.             profile.save()
  68.         
  69.         return True
  70.  
  71.     
  72.     def set_sbx_username(request, username):
  73.         effective_username_field = u'_'.join([
  74.             request.ProjectName,
  75.             'sbx_id'])
  76.         if effective_username_field not in request.session:
  77.             return None
  78.         
  79.         user = User.objects.get(sbxid = request.session[effective_username_field], project = request.ProjectName)
  80.         user.username = username
  81.         user.save()
  82.  
  83. else:
  84.     
  85.     def get_pupil_profile(request):
  86.         effective_username_field = u'_'.join([
  87.             request.ProjectName,
  88.             'user_name'])
  89.         if effective_username_field not in request.session or request.session[effective_username_field] == 'USER':
  90.             return DummyProfile()
  91.         
  92.         user = User.objects.get(username = request.session[effective_username_field], project = request.ProjectName)
  93.         return request.ProjectSettings.UserProfile.objects.get(user = user)
  94.  
  95.     
  96.     def login_pupil(request, username):
  97.         (user, created) = User.objects.get_or_create(username = username, project = request.ProjectName)
  98.         if created:
  99.             user.save()
  100.             profile = request.ProjectSettings.UserProfile(user = user)
  101.             profile.save()
  102.         
  103.         return True
  104.  
  105.     
  106.     def remove_pupil(request, username):
  107.         
  108.         try:
  109.             user = User.objects.get(username = username, project = request.ProjectName)
  110.             user.delete()
  111.         except:
  112.             pass
  113.  
  114.  
  115.